package com.kangye.game.service.impl;

import com.kangye.game.dao.TUserMapper;
import com.kangye.game.pojo.TUser;
import com.kangye.game.service.UpdateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: game_orders
 * @description: 修改用户信息实现服务类
 * @author: lys
 * @create: 2021-09-01 20:51
 **/
@Service
public class UpdateServiceImpl implements UpdateService {
    @Resource
    private TUserMapper tUserMapper;

    @Override
    public int updateTUser(TUser tUser) {
        return tUserMapper.updateTUser(tUser);
    }

    @Override
    public int updateMoney(Integer id, Integer newbalance, Integer oldbalance) {
        Map<String, Integer> map = new HashMap<>();
        Integer balance = newbalance + oldbalance;
        map.put("id", id);
        map.put("balance", balance);
        return tUserMapper.updateMoney(map);
    }

    @Override
    public long findBalance(Integer id) {
        Map<String, Integer> map = new HashMap<>();
        map.put("id", id);
        return tUserMapper.findBalance(map);
    }
}
